/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainPanel.java
 *
 * Created on 2010/08/28, 23:47:58
 */
package sweetvsti.gui;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.border.Border;
import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
import sweetvsti.Settings;
import sweetvsti.Util;

/**
 *
 * @author uimac
 */
public class MainPanel extends javax.swing.JPanel implements MouseListener, KeyListener {

    // JButtonの仮名リスト
    private List kanaButtons = new ArrayList();
    // ボタンで使用するフォント
    private Font buttonFont = new Font(Font.SANS_SERIF, Font.PLAIN, 12);

    /**
     * 仮名のボタン作成。
     * @return JButtonのリスト
     */
    private List createKanaButtons() {
        Map kanaMap = Settings.instance().getKanaMap();
        Set keySet = kanaMap.keySet();

        for (Iterator it = keySet.iterator(); it.hasNext();) {
            JButton button = new JButton();
            button.setText((String) kanaMap.get(it.next()));
            button.addMouseListener(this);
            kanaButtons.add(button);
        }
        return kanaButtons;
    }

    /**
     * ボタン配置。右上から、左下方向に配置していく
     * @param buttons　配置するJButtonのリスト
     * @param position　１つめのボタン位置
     * @param span １つ前のボタンからの、x方向、方向の表示間隔
     * @param buttonSize　ボタンの大きさ
     */
    private void putKanaButtons(List buttons, Point position, Point span, Dimension buttonSize) {
        Border border = new CompoundBorder(new EmptyBorder(0, 0, 0, 0), null);

        for (int i = 0, size = buttons.size() / 5; i < size; ++i) {
            for (int k = 0; k < 5; ++k) {
                JButton button = (JButton) buttons.get(i * 5 + k);
                if (button.getText().isEmpty()) {
                    continue;
                }

                button.setBorder(border);
                button.setFont(buttonFont);
                button.setSize(buttonSize.width, buttonSize.height);

                if (i < 16) {
                    // 上段
                    button.setLocation(
                            position.x - span.x * i,
                            position.y + span.y * k);
                } else {
                    // 下段
                    button.setLocation(
                            position.x - span.x * (i - 16),
                            position.y + span.y * k + span.y * 5 + 5);
                }
                this.kanaPanel.add(button);
            }
        }
    }

    /** Creates new form MainPanel */
    public MainPanel() {

        initComponents();

        this.setSize(Settings.instance().getWidth() - 100, Settings.instance().getHeight() - 50);
        Dimension buttonSize = new Dimension(40, 38);
        Point buttonSpan = new Point(buttonSize.width + 4, buttonSize.height + 4);

        /// あいうえお表作成
        putKanaButtons(createKanaButtons(), new Point(getWidth(), 5), buttonSpan, buttonSize);

        // keyListenerをセット
        this.setFocusable(true);
        this.addKeyListener(this);
        
        KeyPanel keyPanel = (KeyPanel)this.keyPanel;
        if (keyPanel != null)
        {
            keyPanel.reset();
        }
    }

    public void mouseClicked(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {
        if (e.getSource() instanceof JButton) {
            JButton button = (JButton)e.getSource();

            // ボタンの番号を求める
            int button_index = 0;
            for (int i = 0, size = kanaButtons.size(); i < size; ++i) {
                JButton kana = (JButton)kanaButtons.get(i);
                if (kana.getText().isEmpty()) { continue; }
                if (button == kana) { break; }
                ++button_index;
            }

            // 求めた番号をセット
            Settings.instance().setCharactor(button_index);
        }
    }

    public void keyTyped(KeyEvent e) {}
    public void keyReleased(KeyEvent e) {}
    public void keyPressed(KeyEvent e) {
        Integer code = new Integer(e.getKeyCode());
        Map qwertyMap = Settings.instance().getQwertyKanaMap();
        // 番号をセット
        if (qwertyMap.containsKey(code)) {
            Settings.instance().setCharactor(
                    ((Integer)qwertyMap.get(code)).intValue()
                    );
        }

        //Util.openMessageDialog("code:" + code);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        kanaPanel = new javax.swing.JPanel();
        utilPanel = new javax.swing.JPanel();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        baseTuneComboBox = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        durationComboBox = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        mixierPanel = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        keyPanel = new KeyPanel();

        setBackground(new java.awt.Color(51, 51, 51));
        setPreferredSize(new java.awt.Dimension(800, 600));

        kanaPanel.setBackground(javax.swing.UIManager.getDefaults().getColor("textInactiveText"));

        javax.swing.GroupLayout kanaPanelLayout = new javax.swing.GroupLayout(kanaPanel);
        kanaPanel.setLayout(kanaPanelLayout);
        kanaPanelLayout.setHorizontalGroup(
            kanaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 771, Short.MAX_VALUE)
        );
        kanaPanelLayout.setVerticalGroup(
            kanaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 426, Short.MAX_VALUE)
        );

        jTabbedPane1.addTab("五十音", kanaPanel);

        utilPanel.setBackground(new java.awt.Color(55, 55, 55));

        jButton3.setText("書き出し");
        jButton3.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel1.setForeground(new java.awt.Color(204, 204, 204));
        jLabel1.setText("Wave出力ディレクトリ：");

        jLabel2.setForeground(new java.awt.Color(204, 204, 204));
        jLabel2.setText("KanaNoteのWaveファイル分割");

        jButton4.setText("選択");
        jButton4.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel5.setForeground(new java.awt.Color(204, 204, 204));
        jLabel5.setText("jLabel4");
        jLabel5.setText(Settings.instance().getWaveInFile());

        jButton5.setText("選択");
        jButton5.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel6.setForeground(new java.awt.Color(204, 204, 204));
        jLabel6.setText("分割対象Waveファイル：");

        jLabel7.setForeground(new java.awt.Color(204, 204, 204));
        jLabel7.setText("jLabel4");
        jLabel7.setText(Settings.instance().getWaveOutDir());

        baseTuneComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "3", "-2", "-1", "0", "1", "2", "4", "5", "6", "7" }));

        jLabel8.setForeground(new java.awt.Color(204, 204, 204));
        jLabel8.setText("duration：");

        durationComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "240", "480" }));

        jLabel9.setForeground(new java.awt.Color(204, 204, 204));
        jLabel9.setText("base tune：");

        javax.swing.GroupLayout utilPanelLayout = new javax.swing.GroupLayout(utilPanel);
        utilPanel.setLayout(utilPanelLayout);
        utilPanelLayout.setHorizontalGroup(
            utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(utilPanelLayout.createSequentialGroup()
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, utilPanelLayout.createSequentialGroup()
                        .addGap(47, 47, 47)
                        .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, utilPanelLayout.createSequentialGroup()
                        .addGap(115, 115, 115)
                        .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8)
                            .addComponent(jLabel9))))
                .addGap(18, 18, 18)
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, utilPanelLayout.createSequentialGroup()
                        .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, utilPanelLayout.createSequentialGroup()
                        .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(baseTuneComboBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
                    .addComponent(durationComboBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(254, Short.MAX_VALUE))
        );
        utilPanelLayout.setVerticalGroup(
            utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(utilPanelLayout.createSequentialGroup()
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, utilPanelLayout.createSequentialGroup()
                        .addGap(64, 64, 64)
                        .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(utilPanelLayout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel6)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(baseTuneComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(utilPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(durationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addGap(16, 16, 16)
                .addComponent(jButton3)
                .addContainerGap(207, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Utility", utilPanel);

        mixierPanel.setBackground(new java.awt.Color(51, 51, 51));
        mixierPanel.setPreferredSize(new java.awt.Dimension(776, 80));

        jButton1.setText("選択");
        jButton1.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel3.setForeground(new java.awt.Color(204, 204, 204));
        jLabel3.setText("Waveディレクトリ：");

        jLabel4.setForeground(new java.awt.Color(204, 204, 204));
        jLabel4.setText("jLabel4");
        jLabel4.setText(Settings.instance().getWaveBaseDir());

        jButton2.setText("about");
        jButton2.setMargin(new java.awt.Insets(2, 2, 2, 2));
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout mixierPanelLayout = new javax.swing.GroupLayout(mixierPanel);
        mixierPanel.setLayout(mixierPanelLayout);
        mixierPanelLayout.setHorizontalGroup(
            mixierPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mixierPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(233, 233, 233)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(23, 23, 23))
        );
        mixierPanelLayout.setVerticalGroup(
            mixierPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mixierPanelLayout.createSequentialGroup()
                .addGroup(mixierPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(6, 6, 6))
        );

        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

        keyPanel.setLayout(new javax.swing.BoxLayout(keyPanel, javax.swing.BoxLayout.LINE_AXIS));
        jScrollPane1.setViewportView(keyPanel);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mixierPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(mixierPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
   Util.openMessageDialog("SweetVSTi \n\n"
           + "(C) Kazuma Hatta. All Rights Reserved. \n\n"
           + "Copyright(c) 1991, 1999 Free Software Foundation, Inc.");
}//GEN-LAST:event_jButton2ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    File folder = Util.openFolderChooser();
    if (folder != null && folder.isDirectory()) {
        Settings.instance().setWaveBaseDir(folder.getAbsolutePath());
        Settings.instance().setIsWaveBaseDirChanged(true);
        this.jLabel4.setText(folder.getAbsolutePath());
        
        KeyPanel keyPanel = (KeyPanel)(this.keyPanel);
        if (keyPanel != null)
        {
            keyPanel.reset();
        }
    }
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    String baseTune = (String)baseTuneComboBox.getSelectedItem();
    String duration = (String)durationComboBox.getSelectedItem();
    String inFile = Settings.instance().getWaveInFile();
    String outDir = Settings.instance().getWaveOutDir();
    try {
        boolean isSuccess = Util.duplicateWaveFile(new File(inFile), new File(outDir), 
                Integer.valueOf(baseTune), Integer.valueOf(duration));
        if (isSuccess) 
        {
            Util.openMessageDialog("書き出し完了しました");
        }
        else
        {
            Util.openMessageDialog("書き出し失敗しました");
        }
    } catch (Exception ex) {
            Util.openMessageDialog("書き出し失敗しました");
    }
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    File folder = Util.openFolderChooser();
    if (folder != null && folder.isDirectory()) {
        Settings.instance().setWaveOutDir(folder.getAbsolutePath());
      //  Settings.instance().setIsWaveOutDirChanged(true);
        this.jLabel7.setText(folder.getAbsolutePath());
    }
}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    File file = Util.openFileChooser();
    if (file != null && file.isFile()) {
        Settings.instance().setWaveInFile(file.getAbsolutePath());
      //  Settings.instance().setIsWaveOutDirChanged(true);
        this.jLabel5.setText(file.getAbsolutePath());
    }
}//GEN-LAST:event_jButton5ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox baseTuneComboBox;
    private javax.swing.JComboBox durationComboBox;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JPanel kanaPanel;
    private javax.swing.JPanel keyPanel;
    private javax.swing.JPanel mixierPanel;
    private javax.swing.JPanel utilPanel;
    // End of variables declaration//GEN-END:variables
}
